<template>
  <!-- 配件销售单详情 -->
  <div>
    <!-- :fetchapi="fetchapi"
      :params="fetchParams"
      :datakey="'rows'" -->
    <FilterTable
      ref="table"
      :dataSource="tableData"
      height="auto"
      maxHeight="350"
      :columns="columns"
      columnsRef="part_partOutbound_partSalesOutbound_orderDetail"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.columns = columns)"
    >
    </FilterTable>

    <div class="btnWrap">
      <el-button @click="handleClose">取消</el-button>
    </div>
  </div>
</template>

<script>
import { partSalesItem } from '@/api/part/partOut/partSales/index';

export default {
  props: ['partSaleNo'],
  data() {
    return {
      fetchapi: () => {},
      columns: this.createTableColumns(),
      tableData: []
    };
  },
  mounted() {
    this.partSaleNo && this.queryTableData(this.partSaleNo);
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        {
          title: '仓库',
          dataIndex: 'STORAGE_CODE',
          sorter: true,
          editable: false,
          showOverflowTooltip: true,
          editType: 'select',
          editItems: [],
          dictItems: [],
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '库位',
          dataIndex: 'STORAGE_POSITION_CODE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件名称',
          dataIndex: 'PART_NAME',
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件销售单价',
          dataIndex: 'PART_SALES_PRICE',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '不含税单价',
          dataIndex: 'PART_SALES_PRICE_NOTAX',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '配件数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true,
          filterType: 'input'
        },

        {
          title: '配件销售金额',
          dataIndex: 'SALES_AMOUNT',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '配件收费金额',
          dataIndex: 'PART_SALES_AMOUNT',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        }
      ];
    },
    // 查询tabl主数据
    async queryTableData(saleNo) {
      this.$refs.table.START_LOADING();
      try {
        let res = await partSalesItem(saleNo);
        if (res.resultCode == 200) {
          this.tableData = res.data;
        }
      } catch (err) {
        console.log(err, '查询table数据失败');
      } finally {
        this.$refs.table.STOP_LOADING();
      }
    },
    // 点击取消
    handleClose() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.btnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
